const express = require('express');
const logger = require('morgan');
const webpack = require('webpack')
const webpackDevMiddleware = require('webpack-dev-middleware')
const webpackOptions = require('../webpack.config')
webpackOptions.mode = 'development'
const compiler = webpack(webpackOptions)

const app = express();

app.use(webpackDevMiddleware(compiler), {}); //  使用express 模拟一个webpack服务器
app.use(logger('dev'));

app.get('/getUser', (req, res) => { // /api/getUser
    res.json([
        {
            name: 'a',
            age: 1,
        },
    ]);
});

app.listen(3003, () => {
    console.log('server start port=3001');
});
